package come.myStudy;

public class Pont2D extends Object {
	private int x;//类的初始化成员变量是有初始值的
	private int y;
	public Pont2D() {
		
	}
	public Pont2D(int x,int y) {
		this.x = x;
		this.y = y;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getX() {
		return this.x;
	}
	public int getY() {//右键-- source--generate y
		return this.y;
	}
	public void setY(int y) {
		this.y = y;
	}
	@Override
	public String toString() {
		return "["+this.x+","+this.y+"]";
		//return String.format("[%d,%d]", this.x,this.y);
	}
	public double distanceFromOrigin() {
		//return Math.sqrt(x*x+y*y);
		return this.distanceBetweenTwoPoints(new Pont2D());
	}
	public double distanceBetweenTwoPoints(Pont2D otherPoint) {
		double disx = this.x - otherPoint.x;
		double disy = this.y - otherPoint.y;
		return Math.sqrt(disx*disx+disy*disy);
	}
	public void transform(int deltX,int deltY) {
		this.x += deltX;
		this.y += deltY;
	}
	
	public Pont2D mirror() {
		return new Pont2D(-this.x,-this.y);
		
	}
	
}
